Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove async-await pair #134

Merged
merged 1 commit into from
Sep 27, 2020
Merged

Remove async-await pair #134

merged 1 commit into from
Sep 27, 2020

Conversation

jnyrup
Copy link
Contributor

@jnyrup jnyrup commented Sep 26, 2020

As GetOrAddAsync only calls the other GetOrAddAsync method with an extra null parameter it should not be necessary to await the call.
This also makes up for the a missing ConfigureAwait(false) introduced in 218bd23#diff-4a28b127c5a26901c14d4513be185990R165

@svengeance
Copy link
Contributor

Method Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated
DotNetMemoryCache_GetOrAddAsync 372.7 ns 11.15 ns 0.61 ns 1.00 0.0334 - - 280 B
LazyCache_GetOrAddAsync_Proposed 516.4 ns 16.93 ns 0.93 ns 1.39 0.0448 - - 376 B
LazyCache_GetOrAddAsync 584.4 ns 5.17 ns 0.28 ns 1.57 0.0534 - - 448 B

Here's some numbers with the proposed change as well. Good find!

@jnyrup
Copy link
Contributor Author

jnyrup commented Sep 27, 2020

@svengeance Thanks for providing the numbers that confirms the change.

If you're a heap allocation hunter, you might be interested in ClrHeapAllocationAnalyzer

@alastairtree alastairtree merged commit 4fc9fef into alastairtree:master Sep 27, 2020
@jnyrup jnyrup deleted the removeAwait branch September 27, 2020 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants